package chatBot.controller;

import chatBot.entity.Commodity;
import chatBot.service.impl.CommodityServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author a2426
 */
@RestController
@RequestMapping("/gpt")
public class CommodityController {

    private final CommodityServiceImpl commodityService;

    @Autowired
    public CommodityController(CommodityServiceImpl commodityService) {
        this.commodityService = commodityService;
    }

    @GetMapping("/commodities")
    public ResponseEntity<List<Commodity>> getAllCommodities() {
        List<Commodity> commodities = commodityService.findAllCommodities();
        return ResponseEntity.ok(commodities);
    }
}
